package org.springblade.modules.mes.opcua.listener;

import lombok.extern.slf4j.Slf4j;
import org.eclipse.milo.opcua.sdk.client.subscriptions.ManagedDataItem;
import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Slf4j
public class OpcUaListener implements ManagedDataItem.DataValueListener {

	@Resource
	private KeyChangeListener service;

	@Override
	public void onDataValueReceived(ManagedDataItem managedDataItem, DataValue dataValue) {
		service.onDataValueReceived(managedDataItem.getNodeId().getIdentifier().toString(), dataValue.getValue().getValue());
	}
}
